//
//  TBRSurePayOrderC.m
//  TBRentClient
//
//  Created by tonbright on 2018/4/28.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TBRSurePayOrderC.h"
#import "TBRSureOrderUserInfoCell.h"
#import "TBRSureOrderDesCell.h"
#import "TBRDoPayOrderC.h"
#import "TBRSureOrderFootView.h"
@interface TBRSurePayOrderC ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView      *tableView;
@property (nonatomic,strong)NSMutableArray *dataArray;
@property (nonatomic,strong)TBRSureOrderFootView *sureOrderFootView;
@end

@implementation TBRSurePayOrderC
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    [self loadData];
}
- (void)setupUI {
    //设置导航条
    [self setupNavItem];
    [self setupFootView];
    //添加tableView
    [self setupTableView];
}

- (void)setupNavItem {
    self.titleText = @"确认订单";
}

- (void)setupFootView {
    TBRSureOrderFootView *sureOrderFootView = [TBRSureOrderFootView sureOrderFootView];
    self.sureOrderFootView = sureOrderFootView;
    [self.view addSubview:sureOrderFootView];
    [self.sureOrderFootView makeConstraints:^(MASConstraintMaker *make) {
        make.leading.offset(15);
        make.trailing.offset(-15);
        make.bottom.offset(-15);
        make.height.offset(46);
    }];
    __weak typeof(self) weakSelf = self;
    self.sureOrderFootView.sureOrderFootViewBlock = ^{
        TBRDoPayOrderC *doPayOrderC = [[TBRDoPayOrderC alloc] init];
        [weakSelf.navigationController pushViewController:doPayOrderC animated:YES];
    };
}

- (void)setupTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    self.tableView.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.offset(0);
        make.bottom.equalTo(self.sureOrderFootView.top).offset(0);
    }];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableFooterView = [UIView new];
    [self.tableView registerNib:[UINib nibWithNibName:@"TBRSureOrderUserInfoCell" bundle:nil] forCellReuseIdentifier:@"TBRSureOrderUserInfoCellId"];
    [self.tableView registerNib:[UINib nibWithNibName:@"TBRSureOrderDesCell" bundle:nil] forCellReuseIdentifier:@"TBRSureOrderDesCellId"];
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, -45, 0, 0)];
    }
    self.tableView.showsVerticalScrollIndicator = NO;
    
}

#pragma mark - 返回组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

#pragma mark - 返回行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

#pragma mark - 返回每行内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//#import "TBRSureOrderUserInfoCell.h"
//#import "TBRSureOrderDesCell.h"
    if (indexPath.row == 0) {
        TBRSureOrderUserInfoCell *cellUserInfo = [tableView dequeueReusableCellWithIdentifier:@"TBRSureOrderUserInfoCellId" forIndexPath:indexPath];
        return cellUserInfo;
    }
    //自定义cell
    TBRSureOrderDesCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TBRSureOrderDesCellId" forIndexPath:indexPath];
    //设置数据
    //返回
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return indexPath.row == 0 ? 94 : 212;
}

//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
//    UIView
//}
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
//    return 44;
//}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


// MARK: - 加载数据
- (void)loadData {
    [self loadNetData];
}

// MARK: - 获取网络数据-----
- (void)loadNetData {
    //    self.dataArray = @[@{@"messageId":@"beToVip",@"imageName":@"",@"titleName":@"成为高级会员,每单享受九折"},
    //                          @{@"messageId":@"myVip",@"imageName":@"",@"titleName":@"我的会员"},
    //                          @{@"messageId":@"myMessage",@"imageName":@"",@"titleName":@"我的消息"},
    //                          @{@"messageId":@"myKeFu",@"imageName":@"",@"titleName":@"我的客服"},
    //                          @{@"messageId":@"law",@"imageName":@"",@"titleName":@"法律条款与隐私政策"},
    //                          @{@"messageId":@"about",@"imageName":@"",@"titleName":@"关于用车无忧"},
    //                          @{@"messageId":@"score",@"imageName":@"",@"titleName":@"欢迎评分"}
    //                          ];
    //    self.dataArray = [NSArray yy_modelArrayWithClass:[TBRMineInfoBasicModel class] json:tmpArray];
}

@end
